package com.ncu.cloundeoffice.controller;

import com.ncu.cloundeoffice.mapper.TSalaryMapper;
import com.ncu.cloundeoffice.pojo.ResponseResult;
import com.ncu.cloundeoffice.pojo.TSalary;
import com.ncu.cloundeoffice.service.TEmployeeService;
import com.ncu.cloundeoffice.service.TSalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/salary/sobcfg")
public class TSalarySobCfgController {

    @Autowired
    private TSalaryService tSalaryService;

    @Autowired
    private TEmployeeService tEmployeeService;

    /**
     * 获取所有工资账套
     * @return
     */
    @GetMapping("/salaries")
    public List<TSalary> getAllSalary(){
        return tSalaryService.getAllTSalary();
    }

    /**
     * 获取所有员工工资账套
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping("/")
    public ResponseResult getEmployeeWithSalary(@RequestParam(value = "currentPage",defaultValue = "1") int currentPage,
                                                @RequestParam(value = "pageSize",defaultValue = "10") int pageSize){
        return tEmployeeService.getEmployeeWithSalary(currentPage,pageSize);
    }

    /**
     * 更新员工工资账套
     * @param eid
     * @param sid
     * @return
     */
    @PutMapping("/")
    public ResponseResult updateEmployeeSalary(@RequestParam("eid") int eid,@RequestParam("sid") int sid){
        return tEmployeeService.updateEmployeeSalary(eid,sid);
    }
}
